<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <ui:composition template="template.xhtml">        
        <ui:define name="content">
            <h:form>
                <h:commandButton id="cb1" value="list new problems" action="#{listProblemsController.listNewProblems()}"/>
                <h:commandButton id="cb2" value="list in work problems" action="#{listProblemsController.listInWorkProblems()}"/>
                <h:commandButton id="cb3" value="list transfer problems" action="#{listProblemsController.listTransferProblems()}"/>
                <h:commandButton id="cb4" value="list solved problems" action="#{listProblemsController.listSolvedProblems()}"/>
                <h:commandButton id="cb5" value="list all problems" action="#{listProblemsController.listAllProblems()}"/>
                <div>
                    <table id="table1">
                        <tr><td>title</td><td>description</td><td>create date</td><td>creator</td><td>assigner</td>
                            <td>solver</td><td>state</td><td>product related</td><td>operation</td>
                        </tr>
                        <ui:repeat var="p" value="#{listProblemsController.temp}" varStatus="status">
                            <tr>
                                <td>#{p.title}</td><td>#{p.description}</td><td>#{p.dateOfCreation}</td><td>#{p.creator.userName}</td>
                                <td>#{p.assigner.userName}</td><td>#{p.solver.userName}</td><td>#{p.state}</td>
                                <td>#{p.productinvolve.title}</td>
                                <td>
                                    <h:link rendered="#{p.state!='NewlyCreated' and p.state!='Rejected' and p.assigner.id==sessionScope.user.id}"
                                            outcome="rejectProblem" value="reject">
                                        <f:param name="pId" value="#{p.id}"/>
                                    </h:link>

                                    <h:link rendered="#{p.state == 'NewlyCreated' or p.state=='TransferRequest'}" value="assign" outcome="assignProblemToUser">
                                        <f:param name="problemId" value="#{p.id}"/>
                                    </h:link>  
                                </td>
                            </tr>
                        </ui:repeat>
                    </table>  
                </div>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

